package classes.managers {
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	/**
	 * ...
	 * @author Kihoonee
	 */
	public class ViewStateManager {
		private var main:Main;
		private var mc:DisplayObjectContainer;
		private var arr:Array = [];
		
		public function ViewStateManager( _main:Main ) {
			main = _main;
			mc = main as DisplayObjectContainer;
			init();
		}
		
		private function init():void {
			var i:int;
			var length:int = mc.numChildren;
			for ( i = 0; i < length; ++i ) {
				var views:DisplayObject = mc.getChildAt(i);
				
				if ( views is MovieClip ) {
					views.visible = false;
					var obj:Object = { };
					obj.name = views.name;
					obj.mc = views;
					arr.push( obj );
				}
			}
		}
		
		public function viewChange( _name:String ):void {
			for each( var obj:Object in arr ) {
				if ( obj.name.split("_")[0] === _name.split("_")[0] ) {
					obj.mc.visible = true;
					obj.mc.mouseChildren = true;
					obj.mc.mouseEnabled = true;
				}else {
					obj.mc.visible = false;
					obj.mc.mouseChildren = false;
					obj.mc.mouseEnabled = false;
				}
				
				if ( obj.name == "close_btn" ) {
					obj.mc.visible = true;
					obj.mc.mouseChildren = true;
					obj.mc.mouseEnabled = true;
				}
			}
		}
		
		public function viewBomb():void {
			for each( var obj:Object in arr ) {
				obj.mc.visible = false;
				obj.mc.mouseChildren = false;
				obj.mc.mouseEnabled = false;
				
				if ( obj.name == "bomb_mc" ) {
					obj.mc.visible = true;
					obj.mc.mouseChildren = true;
					obj.mc.mouseEnabled = true;
				}
			}
		}
	}
}